//
//  LZEditGroupOrderView.m
//  laziz_Merchant
//
//  Created by ZhaoDongBo on 2016/12/19.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "LZEditGroupOrderView.h"
#import "Masonry.h"


@implementation LZEditGroupOrderView

- (instancetype)init {

    self = [super init];
    if (self)
    {
        self.backgroundColor = UIColorFromRGB(0xffffff, 1);
        [self configView];
        [self addAutoLayout];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = UIColorFromRGB(0xffffff, 1);
        [self configView];
        [self addAutoLayout];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self)
    {
        self.backgroundColor = UIColorFromRGB(0xffffff, 1);
        [self configView];
        [self addAutoLayout];
    }
    return self;
}

- (void)configView {
    [self addSubview:self.titleLabel];
    [self addSubview:self.textField];
    [self addSubview:self.line];
}

- (void)addAutoLayout {
    
    WS(weakSelf);
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.leading.mas_equalTo(10);
        make.width.mas_lessThanOrEqualTo(100);
    }];
    
    [self.textField makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.leading.mas_equalTo(weakSelf.titleLabel.mas_trailing).with.offset(10);
        make.trailing.mas_equalTo(-10);
    }];
    
    [self.line makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.leading.mas_equalTo(10);
        make.trailing.mas_equalTo(-10);
        make.height.mas_equalTo(0.6);
    }];
}

- (UILabel *)titleLabel {
    
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = UIColorFromRGB(0x333333, 1);
        _titleLabel.font = [UIFont systemFontOfSize:15];
    }
    
    return _titleLabel;
}

- (UITextField *)textField {
    
    if (_textField == nil) {
        _textField = [[UITextField alloc] init];
        _textField.font = [UIFont systemFontOfSize:15];
        _textField.textColor = UIColorFromRGB(0x333333, 1);
        _textField.tintColor = UIColorFromRGB(0x33a928, 1);
        [_textField addTarget:self action:@selector(textFieldDidEndEditing:) forControlEvents:UIControlEventEditingDidEnd];
    }
    
    return _textField;
}


- (UIView *)line {
    
    if (_line == nil) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = UIColorFromRGB(0xeeeeee, 1);
    }
    
    return _line;
}

- (void)textFieldDidEndEditing:(UITextField *)textField {
    if (self.textFieldEditDidEndBlock) {
        self.textFieldEditDidEndBlock(textField.text, textField.tag);
    }
}

@end
